import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class GridLayoutFrame extends JFrame {
    JButton button1;
    JButton button2;
    JButton button3;
    JButton button4;
    JButton button5;
    JPanel panel;
    JButton button6;
    JButton button7;
    JButton button8;

    public GridLayoutFrame() {
        button1=new JButton("button1");
        button2=new JButton("button2");
        button3=new JButton("button3");
        button4=new JButton("button4");
        button5=new JButton("button5");
        panel=new JPanel();
        panel.setLayout(new GridLayout(1,3));
        button6=new JButton("button6");
        button7=new JButton("button7");
        button8=new JButton("button8");
        this.setLayout(new GridLayout(2,3));
        this.add(button1);
        this.add(button2);
        this.add(button3);
        this.add(button4);
        this.add(button5);
        this.add(panel);
        panel.add(button6);
        panel.add(button7);
        panel.add(button8);
        this.setTitle("GridLayout Test");
        this.setBounds(0, 0, 600, 400);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }
    
    
    public static void main(String[] args){
        GridLayoutFrame myFrame=new GridLayoutFrame();
    }
    
}
